require 'nokogiri'
require 'rest_client'
require 'rspec'
    file=File.open("redirectRules.xml")
    url_data = []
    doc = Nokogiri::XML(file)
	results = []
   
    doc.xpath("//nbnco:redirectRule").each do |u|
    from_url = u.at("./nbnco:fromUrl").inner_text
    to_url = u.at("./nbnco:toUrl").inner_text
    combined_url = "http://www.nbnco.com.au" + from_url
	actual_url = ''
    RestClient.get(combined_url) do |response, request, result, &body|
    actual_url = response.headers[:location]
	end
	
	results << ({:from_url=>from_url,:to_url=>to_url,:actual_url=>actual_url})
	end
	
	results.each do |r|
	puts "#{r[:from_url]} - #{r[:to_url]} - #{r[:actual_url]}" if r[:to_url] != r[:actual_url]
end


